<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create a collator</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.compare.html">Collator::compare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.create.html">Collator::create</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="collator.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Collator::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Collator::__construct</span> &mdash; <span class="dc-title">Create a collator</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-collator.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Collator::__construct()</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   )</div>

  <p class="para rdfs-comment">
   Creates a new instance of Collator.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-collator.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">locale</code></em></dt>

     <dd>

      <p class="para">
       The locale whose collation rules should be used. Special values for
       locales can be passed in - if null is passed for the locale, the
       default locale collation rules will be used. If empty string (&quot;&quot;) or
       &quot;root&quot; are passed, UCA rules will be used.
      </p>
      <p class="para">
       The Locale attribute is typically the most important attribute for
       correct sorting and matching, according to the user expectations in
       different countries and regions. The default
       <a href="http://www.unicode.org/reports/tr10/" class="link external">&raquo;&nbsp;UCA</a>
       ordering will only sort a few languages such as Dutch and Portuguese
       correctly (&quot;correctly&quot; meaning according to the normal expectations for
       users of the languages). Otherwise, you need to supply the locale to
       UCA in order to properly collate text for a given language. Thus a
       locale needs to be supplied so as to choose a collator that is
       correctly tailored for that locale. The choice of a locale will
       automatically preset the values for all of the attributes to something
       that is reasonable for that locale. Thus most of the time the other
       attributes do not need to be explicitly set. In some cases, the choice
       of locale will make a difference in string comparison performance
       and/or sort key length.
       
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-collator.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns Collator instance.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-collator.construct-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Returns an &quot;empty&quot; object on error. You can use
   <span class="function"><a href="function.intl-get-error-code.html" class="function">intl_get_error_code()</a></span>
   and/or
   <span class="function"><a href="function.intl-get-error-message.html" class="function">intl_get_error_message()</a></span>
   to know what happened.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-collator.construct-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2425">
    <p><strong>Example #1 <span class="function"><strong>Collator::__construct()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$coll&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Collator</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'en_CA'&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-collator.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="collator.create.html" class="function" rel="rdfs-seeAlso">Collator::create()</a> - Create a collator</span></li>
    <li class="member"><span class="function"><a href="collator.create.html" class="function" rel="rdfs-seeAlso">collator_create()</a> - Create a collator</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="collator.compare.html">Collator::compare</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="collator.create.html">Collator::create</a></div>
 <div class="up"><a href="class.collator.html">Collator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
